package com.jkoss.action.jy;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jkoss.biz.IEmpsBiz;
import com.jkoss.biz.jy.JyCompsBiz;
import com.jkoss.biz.jy.StucmpjobBiz;
import com.jkoss.pojo.jy.JiuyeGS;
import com.jkoss.pojo.jy.Stucmpjob;
import com.jkoss.pojo.oa.Emps;
import com.jkoss.tool.Page;

@Controller
@RequestMapping("/jy")
public class StucmpjobAction {
    
	@Autowired
	private StucmpjobBiz scjBiz;
	
	@Autowired
	private JyCompsBiz jybiz;
	
	@Autowired
    private IEmpsBiz  ebiz;
	
	//查询全部
	@RequestMapping("listGw")
	public String listScj(HttpServletRequest req,Page<Stucmpjob> page){
		
		if(page==null){
			page=new Page<Stucmpjob>();
		}
		page.setResults(scjBiz.listPageGw(page));
		req.setAttribute("page", page);
		
		//查询全部公司
	    List<JiuyeGS>  gss=jybiz.listAll();
	    req.setAttribute("gss", gss);
		
	    //查询员工
		List<Emps> emps=ebiz.findAllEmp();
		req.setAttribute("emps", emps);
		
		return "listGw.jsp";
		
	}
	//查看单个
	@RequestMapping("oneGw")
	public String oneGw(HttpServletRequest req,Integer jygwid){
		Stucmpjob gw=scjBiz.findByGwId(jygwid);
		req.setAttribute("gw", gw);		
		return "shGw.jsp";
		
	}
	
	//新增
	@RequestMapping("addGw")
	public String addGw(HttpServletRequest req,Stucmpjob gw){	
		
		String msg=scjBiz.addGw(gw);
		req.setAttribute("msg", msg);
		return listScj(req,null);	
	}
	
	@RequestMapping("delGw")
	public String delGw(HttpServletRequest req,Integer jygwid){
		String msg=scjBiz.delGw(jygwid);
		req.setAttribute("msg", msg);
		return listScj(req,null);	
	}
	
	@RequestMapping("toUpGw")
	public String toUpGw(HttpServletRequest req,Integer jygwid){
		
		Stucmpjob gw=scjBiz.findByGwId(jygwid);
		//查询全部公司
	    List<JiuyeGS>  gss=jybiz.listAll();
	    req.setAttribute("gss", gss);
		
	    //查询员工
		List<Emps> emps=ebiz.findAllEmp();
		req.setAttribute("emps", emps);
		req.setAttribute("gw", gw);		
		return "upGw.jsp";
	}
	
	public String upGw(HttpServletRequest req,Stucmpjob gw){
		return null;
		
	}
}
